﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using Bruce.Data.Linq.Mapping;

namespace Linq2SqliteTest
{
    public partial class Admin : IOrmEntity
    {
        #region IOrmEntity 成员

        public string MapTableName
        {
            get
            {
                TableAttribute att = this.GetType().GetCustomAttributes(typeof(TableAttribute), false)
                                                   .OfType<TableAttribute>()
                                                   .SingleOrDefault();
                if (att != null)
                {
                    return att.Name;
                }

                //没有Attribute标记则视为违反约定
                throw new InvalidOperationException("No TableAttribute instance has been used.");
            }
        }

        #endregion
    }
}
